package stu.day25_day32.day25.day1;

import stu.day25_day32.day25.all.TreeNode;


public class LeetCode101 {
    public boolean isSymmetric(TreeNode root) {
        if(root == null){
            return true;
        }

        return isE(root.left,root.right);

    }

    public boolean isE(TreeNode r1,TreeNode r2){

        if(r1==null&&r2!=null){
            return false;
        }
        if(r2==null&&r1!=null){
            return false;
        }
        if(r2==null&&r1==null){
            return true;
        }
        if(r1.val!=r2.val){
            return false;
        }
        if(!isE(r1.right,r2.left)||!isE(r1.left,r2.right)){
            return false;
        };

        return true;


    }

}
